<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
    <head>
        <title>Hyphenator.js &ndash; Dictionary Checker</title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <script type="text/javascript">
			checkLangSupport = function (lang) {
				var testStrings = [
					//latin: 0
					'abcdefghijklmnopqrstuvwxyz',
					//cyrillic: 1
					'абвгдеёжзийклмнопрстуфхцчшщъыьэюя',
					//arabic: 2
					'أبتثجحخدذرزسشصضطظعغفقكلمنهوي',
					//armenian: 3
					'աբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆ',
					//bengali: 4
					'ঁংঃঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহ়ঽািীুূৃৄেৈোৌ্ৎৗড়ঢ়য়ৠৡৢৣ',
					//devangari: 5
					'ँंःअआइईउऊऋऌएऐओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽािीुूृॄेैोौ्॒॑ॠॡॢॣ',
					//greek: 6
					'αβγδεζηθικλμνξοπρσςτυφχψω',
					//gujarati: 7
					'બહઅઆઇઈઉઊઋૠએઐઓઔાિીુૂૃૄૢૣેૈોૌકખગઘઙચછજઝઞટઠડઢણતથદધનપફસભમયરલળવશષ',
					//kannada: 8
					'ಂಃಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽಾಿೀುೂೃೄೆೇೈೊೋೌ್ೕೖೞೠೡ',
					//lao: 9
					'ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮະັາິີຶືຸູົຼເແໂໃໄ່້໊໋ໜໝ',
					//malayalam: 10
					'ംഃഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനപഫബഭമയരറലളഴവശഷസഹാിീുൂൃെേൈൊോൌ്ൗൠൡൺൻർൽൾൿ',
					//oriya: 11
					'ଁଂଃଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହାିୀୁୂୃେୈୋୌ୍ୗୠୡ',
					//persian: 12
					'أبتثجحخدذرزسشصضطظعغفقكلمنهوي',
					//punjabi: 13
					'ਁਂਃਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਲ਼ਵਸ਼ਸਹਾਿੀੁੂੇੈੋੌ੍ੰੱ',
					//tamil: 14
					'ஃஅஆஇஈஉஊஎஏஐஒஓஔகஙசஜஞடணதநனபமயரறலளழவஷஸஹாிீுூெேைொோௌ்ௗ',
					//telugu: 15
					'ఁంఃఅఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళవశషసహాిీుూృౄెేైొోౌ్ౕౖౠౡ'
					],
					

        		//http://en.wikipedia.org/wiki/List_of_Unicode_characters
        		languages = {en: 0, af: 0, ar: 2, as: 4, bg: 1, bn: 4, ca: 0, cs: 0, cy: 0, da: 0, de: 0, el: 6, eo: 0, es: 0, et: 0, eu: 0, fa: 12, fi: 0, fr: 0, ga: 0, gl: 0, gu: 7, hi: 5, hr: 0, hsb: 0, hu: 0, hy: 3, ia: 0, id: 0, 'is': 0, it: 0, kmr: 0, kn: 8, la: 0, lo: 9, lt: 0, lv: 0, ml: 10, mn: 1, mr: 5, nb: 0, nl: 0, nn: 0, or: 11, pa: 13, pl: 0, pt: 0, ro: 0, ru: 1, 'sr-latn': 0, 'sr-cyrl': 1, sl: 0, 'sr-latn': 0, 'sr-cyrl': 1, sv: 0, ta: 14, te: 15, tk: 0, tr: 0, uk: 1, 'zh-latn': 0},
        		createElem = function (tagname, context) {
					context = context || contextWindow;
					if (document.createElementNS) {
						return context.document.createElementNS('http://www.w3.org/1999/xhtml', tagname);
					} else if (document.createElement) {
						return context.document.createElement(tagname);
					}
				},
				shadow,
				computedHeight,
				bdy = window.document.getElementsByTagName('body')[0];
				
				//create and append shadow-test-element
				shadow = createElem('div', window);
				shadow.id = 'Hyphenator_LanguageChecker';
				shadow.style.width = '5em';
				shadow.style.MozHyphens = 'auto';
				shadow.style['-webkit-hyphens'] = 'auto';
				shadow.style['-ms-hyphens'] = 'auto';
				shadow.style.hyphens = 'auto';
				shadow.style.fontSize = '12px';
				shadow.style.lineHeight = '12px';
				//shadow.style.visibility = 'hidden';
				if (languages.hasOwnProperty(lang)) {
					shadow.lang = lang;
					shadow.style['-webkit-locale'] = "'" + lang + "'";
					shadow.innerHTML = testStrings[languages[lang]];
				} else {
					console.log('test not possible');
					return false;
				}
				bdy.appendChild(shadow);
				
				//measure its height
				//computedHeight = parseInt(window.getComputedStyle(shadow, null).height.slice(0, -2), 10);
				computedHeight = shadow.offsetHeight;
				
				//remove shadow element
				//bdy.removeChild(shadow);

				if (computedHeight > 12) {
					return true;
				} else {
					return false;
				}				
			};

        
        	
			window.onload = function () {
				document.getElementById('checker').onsubmit = function (e) {
					if (e && e.preventDefault) {
						e.preventDefault();
					} else if (window.event) {
						window.event.returnValue = false;
					}
					var lang = document.getElementsByName('language')[0].value;
					var runs = 500, r;
					var s = new Date().getTime();
					for (var i = 0; i<runs; i++) {
						r = checkLangSupport(lang);
					}
					var e = new Date().getTime();
					console.log('Checking ' + lang + ':' + r + ' took ' + (e-s)/runs + 'ms')
				};
			};
        </script>
    </head>
    <body>
    	<h1>Pattern Availability Checker</h1>
    	<p>Checks if a language can natively be hyphenated by the current browser.</p>
		<form action="#" method="post" id="checker">
			<input type="text" name="language" value="de">
			<input type="submit" value="Check!">
		</form>
	</body>
</html>